﻿namespace TS2015.Models
{
    using System;
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Linq;

    public partial class TS2015Context : DbContext
    {
        public TS2015Context()
            : base("name=TS2015Context")
        {
        }

        public virtual DbSet<TbChucNang> TbChucNangs { get; set; }
        public virtual DbSet<TbChucNang_Quyen> TbChucNang_Quyen { get; set; }
        public virtual DbSet<TbChuyenNganh> TbChuyenNganhs { get; set; }
        public virtual DbSet<TbDanToc> TbDanTocs { get; set; }
        public virtual DbSet<TbDiemTotNghiep> TbDiemTotNghieps { get; set; }
        public virtual DbSet<TbDoiTuongUuTien> TbDoiTuongUuTiens { get; set; }
        public virtual DbSet<TbHeDaoTao> TbHeDaoTaos { get; set; }
        public virtual DbSet<TbHuyen> TbHuyens { get; set; }
        public virtual DbSet<TbKhoa> TbKhoas { get; set; }
        public virtual DbSet<TbKhoiThi> TbKhoiThis { get; set; }
        public virtual DbSet<TbKhuVuc> TbKhuVucs { get; set; }
        public virtual DbSet<TbLoaiND> TbLoaiNDs { get; set; }
        public virtual DbSet<TbLoaiTinTuc> TbLoaiTinTucs { get; set; }
        public virtual DbSet<TbMonTotNghiep> TbMonTotNghieps { get; set; }
        public virtual DbSet<TbNganh> TbNganhs { get; set; }
        public virtual DbSet<TbNguoiDung> TbNguoiDungs { get; set; }
        public virtual DbSet<TbSlide> TbSlides { get; set; }
        public virtual DbSet<TbThiSinh> TbThiSinhs { get; set; }
        public virtual DbSet<TbThongBao> TbThongBaos { get; set; }
        public virtual DbSet<TbTinh> TbTinhs { get; set; }
        public virtual DbSet<TbTinTuc> TbTinTucs { get; set; }
        public virtual DbSet<TbTruong> TbTruongs { get; set; }
        public virtual DbSet<TbXepLoaiH> TbXepLoaiHS { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<TbChucNang>()
                .Property(e => e.Link)
                .IsUnicode(false);

            modelBuilder.Entity<TbChucNang>()
                .Property(e => e.Anh)
                .IsUnicode(false);

            modelBuilder.Entity<TbChucNang>()
                .HasMany(e => e.TbChucNang_Quyen)
                .WithRequired(e => e.TbChucNang)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbDanToc>()
                .HasMany(e => e.TbThiSinhs)
                .WithRequired(e => e.TbDanToc)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbDiemTotNghiep>()
                .Property(e => e.MaTS)
                .IsFixedLength();

            modelBuilder.Entity<TbDoiTuongUuTien>()
                .HasMany(e => e.TbThiSinhs)
                .WithRequired(e => e.TbDoiTuongUuTien)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbKhoa>()
                .HasMany(e => e.TbNganhs)
                .WithRequired(e => e.TbKhoa)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbKhoiThi>()
                .Property(e => e.TenKhoiThi)
                .IsFixedLength();

            modelBuilder.Entity<TbKhoiThi>()
                .HasMany(e => e.TbThiSinhs)
                .WithRequired(e => e.TbKhoiThi)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbKhuVuc>()
                .Property(e => e.MaKhuVuc)
                .IsFixedLength();

            modelBuilder.Entity<TbKhuVuc>()
                .HasMany(e => e.TbThiSinhs)
                .WithRequired(e => e.TbKhuVuc)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbLoaiND>()
                .HasMany(e => e.TbChucNang_Quyen)
                .WithRequired(e => e.TbLoaiND)
                .HasForeignKey(e => e.MaQuyen)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbLoaiND>()
                .HasMany(e => e.TbNguoiDungs)
                .WithRequired(e => e.TbLoaiND)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbLoaiTinTuc>()
                .Property(e => e.Anh)
                .IsUnicode(false);

            modelBuilder.Entity<TbLoaiTinTuc>()
                .HasMany(e => e.TbTinTucs)
                .WithRequired(e => e.TbLoaiTinTuc)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbMonTotNghiep>()
                .HasMany(e => e.TbDiemTotNghieps)
                .WithRequired(e => e.TbMonTotNghiep)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbNganh>()
                .HasMany(e => e.TbChuyenNganhs)
                .WithRequired(e => e.TbNganh)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbNguoiDung>()
                .Property(e => e.TenDangNhap)
                .IsFixedLength();

            modelBuilder.Entity<TbNguoiDung>()
                .Property(e => e.MatKhau)
                .IsFixedLength();

            modelBuilder.Entity<TbSlide>()
                .Property(e => e.Anh)
                .IsUnicode(false);

            modelBuilder.Entity<TbThiSinh>()
                .Property(e => e.MaTS)
                .IsFixedLength();

            modelBuilder.Entity<TbThiSinh>()
                .Property(e => e.MaKhuVuc)
                .IsFixedLength();

            modelBuilder.Entity<TbThiSinh>()
                .Property(e => e.GioiTinh)
                .IsFixedLength();

            modelBuilder.Entity<TbThiSinh>()
                .Property(e => e.SoDienThoai)
                .IsFixedLength();

            modelBuilder.Entity<TbThiSinh>()
                .Property(e => e.CMND)
                .IsFixedLength();

            modelBuilder.Entity<TbThiSinh>()
                .Property(e => e.NamTotNghiep)
                .IsFixedLength();

            modelBuilder.Entity<TbThiSinh>()
                .Property(e => e.Anh)
                .IsUnicode(false);

            modelBuilder.Entity<TbThongBao>()
                .Property(e => e.NguoiGui)
                .IsFixedLength();

            modelBuilder.Entity<TbThongBao>()
                .Property(e => e.NguoiNhan)
                .IsFixedLength();

            modelBuilder.Entity<TbTinh>()
                .HasMany(e => e.TbTruongs)
                .WithRequired(e => e.TbTinh)
                .HasForeignKey(e => e.MaTinh)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<TbTinTuc>()
                .Property(e => e.AnhDaiDien)
                .IsUnicode(false);

            modelBuilder.Entity<TbTruong>()
                .HasMany(e => e.TbThiSinhs)
                .WithRequired(e => e.TbTruong)
                .WillCascadeOnDelete(false);
        }
    }
}
